import requests
import json
import base64

organization = 'HKITDevOps'
project = 'HKWebApp'
repository_id = '0170f2e7-3229-445f-a217-5b11c8550f87'
pat = 'rohvxi4cveemyk2ttapc5whjn22ohjfmeabdds7xh4nn7ls7uctq'

url = f"https://dev.azure.com/{organization}/{project}/_apis/source/repositories/{repository_id}/changesets?api-version=6.0"
headers = {
    'Authorization': 'Bearer ' + pat,
    'Content-Type': 'application/json'
}
encode_pat = base64.b64encode(pat.encode('utf-8'))
print(str(encode_pat,'utf-8'))
exit()

response = requests.get(url, headers=headers)

if response.status_code == 200:

    changesets = response.json()
    for changeset in changesets:
        print(json.dumps(changeset, indent=2))
else:
    print(f"Failed to get changesets, status code: {response.status_code}")
    print(response.text)
